<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
  <ul class="nav nav-tabs">
    <li><a href="{:url('Goods/index')}">商品列表</a></li>
    <li class="active"><a href="{:url('Goods/edit', ['id' => $goods['id']])}">编辑商品</a></li>
  </ul>
  <form action="{:url('Goods/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
    <input type="hidden" name="id" value="{$goods.id}">
    <div class="form-group">
      <label class="col-sm-2 control-label">标题</label>
      <div class="col-md-6 col-sm-10">
        <input type="text" class="form-control" name="title" value="{$goods.title}">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">运费</label>
      <div class="col-md-6 col-sm-10">
        <input type="text" class="form-control" name="price" value="{$goods.price}">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">分类ID</label>
      <div class="col-md-6 col-sm-10">
        <input type="text" class="form-control" name="gid" value="{$goods.gid}">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">运营类型</label>
      <div class="col-md-6 col-sm-10">
        <select name="type" class="form-control">
          <option value="0" <eq name="goods.type" value="0">selected</eq>>自营</option>
          <option value="1" <eq name="goods.type" value="1">selected</eq>>旗舰店</option>
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">商品状态</label>
      <div class="col-md-6 col-sm-10">
        <select name="switch" class="form-control">
          <option value="0" <eq name="goods.switch" value="0">selected</eq>>缺货</option>
          <option value="1" <eq name="goods.switch" value="1">selected</eq>>上架</option>
          <option value="2" <eq name="goods.switch" value="2">selected</eq>>下架</option>
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label">图片<span class="form-required">*</span></label>
      <div class="col-md-6 col-sm-10">
        <input id="photo-1" type="hidden" name="image" value="{$goods.image}">
        <input id="photo-1-name" class="form-control" type="text" name="" value="{$goods.image_name}" title="图片名称" disabled readonly>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label"></label>
      <div class="col-md-6 col-sm-10">
        <img id="photo-1-preview" src="/upload/{$goods.image}" width="40px">
        <a href="javascript:uploadOneImage('图片上传','#photo-1');" class="btn btn-primary">上传</a>
      </div>
    </div>
    <div class="form-group">
      <label for="booklet" class="col-sm-2 control-label">图集</label>
      <div class="col-md-6 col-sm-10">
        <foreach name="$goods['images']" item="v">
          <img src="/upload/{$goods.image}" style="width: 40px">
        </foreach>
        <div id="imagesContainer"></div>
        <div class="margin-top-10">
          <a class="btn btn-default" href="javascript:uploadMultiImage('图片上传','#imagesContainer','photos-item-wrapper');">选择图片</a>
        </div>
      </div>
    </div>
    <div class="form-group">
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" class="btn btn-primary js-ajax-submit">提交</button>
      </div>
    </div>
  </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/html" id="photos-item-wrapper">
  <div style="display: flex;align-items: center;border: 1px solid #ddd;padding: 5px;margin-top: 10px;">
    <div><img id="photo-{id}-preview" src="{url}" class="img-thumbnail" style="width: 100px;height: 50px;"></div>
    <div style="margin-left: 10px;">{name}</div>
    <input id="photo-{id}" type="hidden" name="images[]" value="{filepath}">
  </div>
</script>
</body>
</html>
